<template>
  <div id="app" :class="{'vip':pifuDataFn!=1}" :languageData=languageData >
    <router-view/>
    <div   v-loading="loadingFn.loading"
           :element-loading-text="loadingFn.text"
           element-loading-spinner="el-icon-loading">

    </div>
  </div>
</template>
<style scoped>

</style>
<script>
  import {mapState, mapActions} from 'vuex'
  import lang from 'element-ui/lib/locale/lang/en'
  import lang2 from 'element-ui/lib/locale/lang/zh-CN'
  import locale from 'element-ui/lib/locale'
  import Public from '@/vuex/public'
export default {
  name: 'app',
  created () {
    this.$store.commit('httpTo', this.$http)
    this.getjson()
    var usr = sessionStorage.getItem('user') || '';
    if(usr =="" ){
    } else {
      usr = JSON.parse(usr);

      if(usr.level){
        this.$store.commit('pifu', usr.level)
      }
    }

  },
  data(){
    return{
      t:''
    }
  },
  methods:{
    getjson(){
      this.$http.get(Public.api+'/static/stationCode.json').then(function (res) {

        this.$store.commit('stationTo', res.body);
      })
    },
  },
  computed: {
    pifuDataFn: function (){
      var parm = this.pifuData
      return parm
    },
    languageData: function () {
      var parm = this.language
      if (parm) {
        if (parm.check == 'Chinese') {
          parm = parm.Chinese
          locale.use(lang2)
        }
        if (parm.check == 'English') {
          parm = parm.English
          locale.use(lang)
//            this.formConfig.labelWidth = '200px'
//            dom.style = 'width:620px'
        }
        // 替换 其他交互数据
//          this.updateDate(parm)
      }
      return 1
    },
    loadingFn: function () {
      var parm = this.loading;
      var _this = this;
      if(parm.loading == true){
        this.t  = setTimeout(function () {
          parm.loading = false;
          _this.openError('链接超时')
          this.$store.commit('commitLoading', {loading:false,text:'请稍后!'})
        },20000)
      }else {
        if(this.t){
          clearTimeout(this.t)
        }
      }

      return parm
    },
    ...mapState([
      'pifuData',
      'language',
      'loading'
    ])
  },

}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  height: 100%;
}
</style>
